"""
@Description :   工具，将浮点数 csv 转成 hex
@Author      :   tqychy 
@Time        :   2023/10/09 16:45:07
"""

import pandas as pd
import struct

input_path = 'params/fc2_bias.csv'
output_path = "./fc2_bias.hex"

data_frame = pd.read_csv(input_path, header=None, index_col=None)
print(data_frame.shape)
float_array = data_frame.values.flatten()
hex_array = [struct.pack('!f', value).hex() for value in float_array]

with open(output_path, "w") as f:
    for hex in hex_array:
        f.write(str(hex) + '\n')